//package org.guoqiang.datasource.handler;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.domain.EntityScan;
//import org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties;
//import org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings;
//import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.jdbc.DataSourceBuilder;
//import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.DependsOn;
//import org.springframework.context.annotation.Primary;
//import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
//
//import javax.sql.DataSource;
//import java.util.Map;
//
//
//@EntityScan(basePackages = "org.guoqiang.datasource")
//@Configuration
//public class DataSourceConfig {
//
//
//    @Primary
//    @Bean("defaultDataSource")
//    @ConfigurationProperties(prefix = "spring.datasource")
//    public DataSource dataSource() {
//        return DataSourceBuilder.create().build();
//    }
//
//
//    @Bean
//    @Primary
//    @DependsOn({"springUtils", "defaultDataSource"})
//    public DynamicDataSource dynamicDataSource() {
//        DynamicDataSource dynamicDataSource = new DynamicDataSource();
//        dynamicDataSource.setTargetDataSources(DynamicDataSource.dataSourcesMap);
//        return dynamicDataSource;
//    }
//
//
//    @Autowired
//    private JpaProperties jpaProperties;
//
//////    @Autowired
//////    private HibernateProperties hibernateProperties;
////
////    @Bean("entityManagerFactorySlave")
////    public LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean(EntityManagerFactoryBuilder builder) {
//////        Map<String, Object> properties = hibernateProperties.determineHibernateProperties(
//////                jpaProperties.getProperties(), new HibernateSettings());
////
////        return builder.dataSource(dataSource())
////                .packages("org.guoqiang.datasource")
////                .persistenceUnit("slavePersistenceUnit")
////                .build();
////    }
//
//}
